class ActusController < ApplicationController
	before_filter :charge_candidat
	
	def charge_candidat
		@candidat = Candidat.find(params[:candidat_id])
	end
  # GET /actus
  # GET /actus.xml
  def index
    @actus = @candidat.actus.find(:all)

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @actus }
    end
  end

  # GET /actus/1
  # GET /actus/1.xml
  def show
    @actu = @candidat.actus.find(params[:id])

    respond_to do |format|
      format.html # _question.html.erb
      format.xml  { render :xml => @actu }
    end
  end

  # GET /actus/new
  # GET /actus/new.xml
  def new
    @actu = @candidat.actus.build

    respond_to do |format|
      format.html
      format.xml  { render :xml => @actu }
    end
  end

  # GET /actus/1/edit
  def edit
    @actu = @candidat.actus.find(params[:id])
  end

  # POST /actus
  # POST /actus.xml
  def create
    @actu = @candidat.actus.build(params[:actu])

    respond_to do |format|
      if @actu.save
        flash[:notice] = 'Actu was successfully created.'
        format.html { redirect_to candidat_url(@candidat) }
        format.xml  { render :xml => @actu, :status => :created, :location => @actu }
      else
        format.html { redirect_to candidat_url(@candidat) }
        format.xml  { render :xml => @actu.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /actus/1
  # PUT /actus/1.xml
  def update
    @actu = @candidat.actus.find(params[:id])

    respond_to do |format|
      if @actu.update_attributes(params[:actu])
        flash[:notice] = 'Actu was successfully updated.'
        format.html { redirect_to candidat_actu_url(@candidat, @actu) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @actu.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /actus/1
  # DELETE /actus/1.xml
  def destroy
    @actu = @candidat.actus.find(params[:id])
    @actu.destroy

    respond_to do |format|
      format.html { redirect_to candidat_actus_path(@candidat) }
      format.xml  { head :ok }
    end
  end
end
